package com.settlement.system.reply;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.settlement.system.common.enums.ReturnStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * @author hsiang
 */
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}, ignoreUnknown = true)
public class ObjectDataResponse<T> {

    private static final long serialVersionUID = 1862906172390850647L;

    @ApiModelProperty(value = "响应主体")
    private T data;

    @ApiModelProperty(value = "返回码")
    private int code = 200;

    @ApiModelProperty(value = "返回码对于的信息")
    private String message;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public ObjectDataResponse(T data) {
        this.data = data;
    }

    public ObjectDataResponse(ReturnStatusEnum returnStatusEnum) {
        this.code = returnStatusEnum.getValue();
        this.message = returnStatusEnum.getText();
    }

    public ObjectDataResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ObjectDataResponse(T data, ReturnStatusEnum returnStatusEnum) {
        this.data = data;
        this.code = returnStatusEnum.getValue();
        this.message = returnStatusEnum.getText();
    }

    public ObjectDataResponse(T data, int code, String message) {
        this.data = data;
        this.code = code;
        this.message = message;
    }


}
